package cc.rengu.igas.momp.core.service.trans;

import cc.rengu.igas.momp.common.constant.CommonConstant;
import cc.rengu.igas.momp.common.dao.*;
import cc.rengu.igas.momp.common.dao.impl.*;
import cc.rengu.igas.momp.common.entity.*;
import cc.rengu.igas.momp.common.enums.*;
import cc.rengu.igas.momp.common.model.bean.*;
import cc.rengu.igas.momp.common.util.CommonMessageCheck;
import cc.rengu.igas.momp.common.util.JsonOperation;
import cc.rengu.igas.momp.facade.bean.*;
import cc.rengu.igas.momp.facade.request.QueryMchntFeeDiscountMcDetailInfoRequest;
import cc.rengu.igas.momp.facade.response.QueryMchntFeeDiscountMcDetailInfoResponse;
import cc.rengu.oltp.service.base.RadpService;
import cc.rengu.oltp.service.common.constant.TreeNodeConstant;
import cc.rengu.oltp.service.common.enums.ChannelEnum;
import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.BizResponse;
import cc.rengu.oltp.utility.bean.PageInfo;
import cc.rengu.oltp.utility.bean.PageResult;
import cc.rengu.oltp.utility.util.ConvertUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.base.StringUtil;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 商户手续费优惠类营销活动详情查询功能实现
 *
 * @author Jinan Liu
 * @date 2020/3/24 15:20
 */
public class QueryMchntFeeDiscountMcDetailInfoService extends RadpService {

    private String globalInstId;
    private String globalQueryType;
    private String globalQueryRole;
    private String globalQueryId;
    private String globalQueryOrgId;
    private String globalMcNo;

    @Override
    protected int bizInit(String s) {
        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    protected int bizProcess(String s, int i) {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();

        try {

            QueryMchntFeeDiscountMcDetailInfoRequest queryMchntFeeDiscountMcDetailInfoRequest = new QueryMchntFeeDiscountMcDetailInfoRequest();
            ConvertUtil.convertOutput(queryMchntFeeDiscountMcDetailInfoRequest);

            QueryMchntFeeDiscountMcDetailInfoResponse queryMchntFeeDiscountMcDetailInfoResponse = new QueryMchntFeeDiscountMcDetailInfoResponse();
            queryMchntFeeDiscountMcDetailInfoResponse.setHeader(queryMchntFeeDiscountMcDetailInfoRequest.getHeader());
            BizResponse<QueryMchntFeeDiscountMcDetailInfoResponse> bizResponse = new BizResponse<>();
            bizResponse.setResult(queryMchntFeeDiscountMcDetailInfoResponse);

            String timeStamp = new SimpleDateFormat(CommonConstant.TIMESTAMP_FORMAT).format(new Date());
            globalQueryType = queryMchntFeeDiscountMcDetailInfoRequest.getQueryType();
            globalQueryId = queryMchntFeeDiscountMcDetailInfoRequest.getQueryId();
            globalQueryOrgId = queryMchntFeeDiscountMcDetailInfoRequest.getQueryOrgId();
            globalQueryRole = queryMchntFeeDiscountMcDetailInfoRequest.getQueryRole();
            globalInstId = queryMchntFeeDiscountMcDetailInfoRequest.getHeader().getInstId();
            globalMcNo = queryMchntFeeDiscountMcDetailInfoRequest.getMcNo();
            rglog.info("机构<{}>在<{}>由<{}>开始查询商户手续费优惠类营销活动详细信息流程", globalInstId, timeStamp, globalQueryId);

            /* 报文检查 */
            CommonMessageCheck.checkBizMessageHeader(globalQueryType, globalQueryId, globalQueryRole, rglog);

            /* 检查操作员所属机构号 */
            if (StringUtil.isNullorEmpty(globalQueryOrgId)) {
                rglog.error("法人机构号<{}>的操作员<{}>的所属机构为空!", globalInstId, globalQueryId);
                throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
            }

            /* 检查营销活动编号 */
            if (StringUtil.isNullorEmpty(globalMcNo)) {
                rglog.error("法人机构号<{}>的操作员<{}>的营销活动编号为空!", globalInstId, globalQueryId);
                throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
            }

            // 服务调用
            BizResponse<QueryMchntFeeDiscountMcDetailInfoResponse> bizResponseNew = queryMoneyOffMcDetailInfo(xmlTreeUtil, queryMchntFeeDiscountMcDetailInfoRequest, queryMchntFeeDiscountMcDetailInfoResponse);

            ConvertUtil.convertInput(bizResponseNew.getResult());

        } catch (BizException e) {
            try {
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_CODE, e.getCode());
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_DESC, e.getMessage());
            } catch (Exception e1) {
                rglog.error(StringUtil.ExceptionToString(e1));
            }
        } catch (Exception e) {
            rglog.error(StringUtil.ExceptionToString(e));
            try {
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_CODE, OltpRpcdEnum.OLTP_PROCESS_ERROR.getRespCode());
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_DESC, OltpRpcdEnum.OLTP_PROCESS_ERROR.getRespDesc());
            } catch (Exception e1) {
                rglog.error(StringUtil.ExceptionToString(e1));
            }
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    protected int bizTerminate(String s) {
        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 查询商户手续费减免类营销活动详细信息
     *
     * @param xmlTreeUtil                               内部XML树
     * @param queryMchntFeeDiscountMcDetailInfoRequest  商户手续费商户手续费减免类活动详情查询接口请求对象
     * @param queryMchntFeeDiscountMcDetailInfoResponse 商户手续费商户手续费减免类活动详情查询接口应答对象
     * @return cc.rengu.oltp.service.model.BizResponse<cc.rengu.igas.momp.facade.response.QueryMchntFeeDiscountMcDetailInfoResponse> 商户手续费商户手续费减免类活动详情查询接口应答对象
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 14:50
     */
    private BizResponse<QueryMchntFeeDiscountMcDetailInfoResponse> queryMoneyOffMcDetailInfo(XmlTreeUtil xmlTreeUtil, QueryMchntFeeDiscountMcDetailInfoRequest queryMchntFeeDiscountMcDetailInfoRequest, QueryMchntFeeDiscountMcDetailInfoResponse queryMchntFeeDiscountMcDetailInfoResponse) throws Exception {

        BizResponse<QueryMchntFeeDiscountMcDetailInfoResponse> bizResponse = new BizResponse<>();

        /* 判断查询类型 */
        MfdMcListInfoInObj mfdMcListInfoInObj = new MfdMcListInfoInObj();

        /* 机构编码 */
        mfdMcListInfoInObj.setInstId(globalInstId);

        /* 营销活动编号 */
        mfdMcListInfoInObj.setMcNo(globalMcNo);

        /* 根据角色权限查询数据 */
        if (QueryTypeEnum.BANK_QUERY_TYPE.getQueryTypeCode().equals(globalQueryType)) {
            /* 银行人员,需要拼接营销活动机构信息表查询 */

            /* 机构编号 */
            if (!StringUtil.isNullorEmpty(globalQueryOrgId)) {
                mfdMcListInfoInObj.setOrgId(globalQueryOrgId);
            }

            /* 银行人员查询营销活动详细信息 */
            queryMfdMcDetailInfoByBank(queryMchntFeeDiscountMcDetailInfoResponse, mfdMcListInfoInObj);
        } else {
            /* 其他查询角色不支持 */
            rglog.error("当前<{}>角色的查询用户<{}>无权限操作数据!", globalQueryRole, globalQueryType);
            throw new BizException(RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespCode(), RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespDesc());
        }

        bizResponse.setRspSysId(ChannelEnum.MOMP.getChannelType());
        bizResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        bizResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());

        queryMchntFeeDiscountMcDetailInfoResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        queryMchntFeeDiscountMcDetailInfoResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());
        bizResponse.setResult(queryMchntFeeDiscountMcDetailInfoResponse);

        return bizResponse;
    }

    /**
     * 银行人员查询营销活动详细信息
     *
     * @param queryMchntFeeDiscountMcDetailInfoResponse 商户手续费商户手续费减免类活动详情查询接口应答对象
     * @param mfdMcListInfoInObj                        营销活动列表查询使用实体类入参
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:58
     */
    private void queryMfdMcDetailInfoByBank(QueryMchntFeeDiscountMcDetailInfoResponse queryMchntFeeDiscountMcDetailInfoResponse, MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {

        if (QueryRoleEnum.BANK_BASIC_QUERY_ROLE.getQueryRoleCode().equals(globalQueryRole) ||
                QueryRoleEnum.BANK_PUBLISH_QYERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {
            TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo;

            if (QueryRoleEnum.BANK_BASIC_QUERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {

                /* 银行录入岗流程 */
                tmMcMchntFeeDiscountInfo = selectMfdMcDetailInfoByBankBasicRole(mfdMcListInfoInObj);
                if (null == tmMcMchntFeeDiscountInfo) {
                    rglog.error("机构<{}>的商户手续费减免类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                    throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
                }
            } else {

                /* 银行发布岗流程 */
                tmMcMchntFeeDiscountInfo = selectMfdMcDetailInfoByBankPublishRole(mfdMcListInfoInObj);
                if (null == tmMcMchntFeeDiscountInfo) {
                    rglog.error("机构<{}>的商户手续费减免类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                    throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
                }
            }

            /* 银行操作员和发布员都是从正式表查询数据,除了营销活动基本表外其他表查询语句相同 */

            /* 查询营销活动机构信息 */
            List<TMMcOrgInfo> mcOrgInfoList = getAllMcOrgListInfo();
            /* 查询营销活动商户信息 */
            /*List<Object> mcMchntInfoList = getAllMcMchntListInfo();*/
            /* 查询营销活动规则信息 */
            List<TMMcMchntFeeDiscountRuleInfo> tmMcMchntFeeDiscountRuleInfoList = getAllMcRuleListInfo();
            /* 查询营销活动支付产品信息 */
            List<TMMcProductInfo> mcProductInfoList = getAllMcProductListInfo();
            /* 拼接交易信息 */
            MchntFeeDiscountMcInfoBean mchntFeeDiscountMcInfoBean = convertMcInfo(tmMcMchntFeeDiscountInfo);
            queryMchntFeeDiscountMcDetailInfoResponse.setMcInfoObj(mchntFeeDiscountMcInfoBean);
            List<McOrgInfoBean> mcOrgInfoBeanList = mcOrgInfoList.stream().map(this::convertMcOrgInfo).collect(Collectors.toList());
            queryMchntFeeDiscountMcDetailInfoResponse.setOrgInfoList(mcOrgInfoBeanList);
            /** 营销活动详情接口去除商户信息 用户信息返回内容 */
            /*
            List<McMchntInfoBean> mcMchntInfoBeanList = new ArrayList<>();
            if(null != mcMchntInfoList && !mcMchntInfoList.isEmpty()){
                mcMchntInfoBeanList = mcMchntInfoList.stream().map(this::convertMcMchntInfo).collect(Collectors.toList());
            }
            queryMchntFeeDiscountMcDetailInfoResponse.setMchntInfoList(mcMchntInfoBeanList);
            */
            List<MchntFeeDiscountRuleInfoBean> mchntFeeDiscountRuleInfoBeanList = new ArrayList<>();
            if (null != tmMcMchntFeeDiscountRuleInfoList && !tmMcMchntFeeDiscountRuleInfoList.isEmpty()) {
                mchntFeeDiscountRuleInfoBeanList = tmMcMchntFeeDiscountRuleInfoList.stream().map(this::convertMcRuleInfo).collect(Collectors.toList());
            }
            queryMchntFeeDiscountMcDetailInfoResponse.setRuleInfoList(mchntFeeDiscountRuleInfoBeanList);
            List<McProductInfoBean> mcProductInfoBeanList = new ArrayList<>();
            if (null != mcProductInfoList && !mcProductInfoList.isEmpty()) {
                mcProductInfoBeanList = mcProductInfoList.stream().map(this::convertMcProductInfo).collect(Collectors.toList());
            }
            queryMchntFeeDiscountMcDetailInfoResponse.setProductInfoList(mcProductInfoBeanList);

        } else if (QueryRoleEnum.BANK_AUDIT_QYERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {

            /* 银行审批岗流程 */
            TMPlatBizTmp tmPlatBizTmp = selectMfdMcDetailInfoByBankAuditRole(mfdMcListInfoInObj);
            if (null == tmPlatBizTmp) {
                rglog.error("机构<{}>的商户手续费减免类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
            }

            /* 取临时表中所有数据 */
            MoMcListInfoInObj moMcListInfoInObj = new MoMcListInfoInObj();
            moMcListInfoInObj.setInstId(globalInstId);
            moMcListInfoInObj.setMcNo(globalMcNo);
            List<TMPlatBizTmp> tmPlatBizTmpList = getAllMcTmpInfo(moMcListInfoInObj);
            if (null == tmPlatBizTmpList || tmPlatBizTmpList.isEmpty()) {
                rglog.error("机构<{}>的商户手续费减免类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
            }

            /* 拆分数据 */

            /* 转换营销活动基本信息 */
            MchntFeeDiscountMcInfoBean mchntFeeDiscountMcInfoBean = convertTmpMcInfo(tmPlatBizTmp);

            /* 转换营销活动机构信息 */
            List<TMPlatBizTmp> tmPlatBizTmpOrgList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_ORG_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McOrgInfoBean> mcOrgInfoBeanList = tmPlatBizTmpOrgList.stream().map(this::convertTmpMcOrgInfo).collect(Collectors.toList());

            /* 查询营销活动商户信息 */
            /** 营销活动详情接口去除商户信息 用户信息返回内容 */
            /*
            List<TMPlatBizTmp> tmPlatBizTmpMchntList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McMchntInfoBean> mcMchntInfoBeanList = tmPlatBizTmpMchntList.stream().map(this::convertTmpMcMchntInfo).collect(Collectors.toList());
            */
            /* 查询营销活动规则信息 */
            List<TMPlatBizTmp> tmPlatBizTmpRuleList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_MFD_RULE_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<MchntFeeDiscountRuleInfoBean> mchntFeeDiscountRuleInfoBeanList = tmPlatBizTmpRuleList.stream().map(this::convertTmpMcRuleInfo).collect(Collectors.toList());

            /* 查询营销活动支付产品信息 */
            List<TMPlatBizTmp> tmPlatBizTmpProdList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_PROD_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McProductInfoBean> mcProductInfoBeanList = tmPlatBizTmpProdList.stream().map(this::convertTmpMcProductInfo).collect(Collectors.toList());

            /* 拼接交易信息 */
            queryMchntFeeDiscountMcDetailInfoResponse.setMcInfoObj(mchntFeeDiscountMcInfoBean);
            queryMchntFeeDiscountMcDetailInfoResponse.setOrgInfoList(mcOrgInfoBeanList);
            /** 营销活动详情接口去除商户信息 用户信息返回内容 */
            /*
            queryMchntFeeDiscountMcDetailInfoResponse.setMchntInfoList(mcMchntInfoBeanList);
            */
            queryMchntFeeDiscountMcDetailInfoResponse.setRuleInfoList(mchntFeeDiscountRuleInfoBeanList);
            queryMchntFeeDiscountMcDetailInfoResponse.setProductInfoList(mcProductInfoBeanList);

        } else {
            /* 其他查询角色不支持 */
            rglog.error("当前<{}>角色的查询用户<{}>无权限操作数据!", globalQueryRole, globalQueryType);
            throw new BizException(RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespCode(), RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespDesc());
        }

    }

    /**
     * 银行操作员查询营销活动基本信息表数据(正式表)
     *
     * @param mfdMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMMcMchntFeeDiscountInfo selectMfdMcDetailInfoByBankBasicRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectMfdMcDetailInfoByBankBasicRole(mfdMcListInfoInObj);
    }

    /**
     * 银行审批员查询营销活动基本信息表数据
     *
     * @param mfdMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMPlatBizTmp selectMfdMcDetailInfoByBankAuditRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {
        PlatBizTmpMapper platBizTmpMapper = new PlatBizTmpMapperImpl();
        return platBizTmpMapper.selectMfdMcDetailInfoByBankAuditRole(mfdMcListInfoInObj);
    }

    /**
     * 银行发布员查询营销活动基本信息表数据
     *
     * @param mfdMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMMcMchntFeeDiscountInfo selectMfdMcDetailInfoByBankPublishRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectMfdMcDetailInfoByBankPublishRole(mfdMcListInfoInObj);
    }

    /**
     * 获取营销活动机构信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcOrgInfo> 营销活动机构信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:36
     */
    private List<TMMcOrgInfo> getAllMcOrgListInfo() throws Exception {

        McOrgInfoMapper mcOrgInfoMapper = new McOrgInfoMapperImpl();
        return mcOrgInfoMapper.selectMcOrgInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动商户信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcMchntInfo> 营销活动商户信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:35
     */
    private List<Object> getAllMcMchntListInfo() throws Exception {
        List<Object> tmMcMchntInfoList = new ArrayList<>();
        PageInfo pageInfo = new PageInfo();
        int i = 0;
        pageInfo.setPageIndex(i);
        pageInfo.setPageSize(9999);
        TMMcMchntInfo tmMcMchntInfo = new TMMcMchntInfo();
        tmMcMchntInfo.setInstId(globalInstId);
        tmMcMchntInfo.setMcNo(globalMcNo);
        McMchntInfoMapper mcMchntInfoMapper = new McMchntInfoMapperImpl();
        PageResult tmMcMchntInfoPageInfo = mcMchntInfoMapper.selectMcMchntInfoList(tmMcMchntInfo, pageInfo);
        if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
            tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
        }
        while (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult() && tmMcMchntInfoPageInfo.getResult().size() >= 1) {
            i++;
            pageInfo.setPageIndex(i);
            tmMcMchntInfoPageInfo = mcMchntInfoMapper.selectMcMchntInfoList(tmMcMchntInfo, pageInfo);
            if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
                tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
            }
        }
        return tmMcMchntInfoList;
    }

    /**
     * 获取营销活动规则信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountRuleInfo> 商户手续费减免类营销活动规则信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:40
     */
    private List<TMMcMchntFeeDiscountRuleInfo> getAllMcRuleListInfo() throws Exception {

        McRuleInfoMapper mcRuleInfoMapper = new McRuleInfoMapperImpl();
        return mcRuleInfoMapper.selectMchntFeeDiscountRuleInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动支付产品信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcProductInfo> 营销活动产品信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:41
     */
    private List<TMMcProductInfo> getAllMcProductListInfo() throws Exception {

        McProductInfoMapper mcProductInfoMapper = new McProductInfoMapperImpl();
        return mcProductInfoMapper.selectMcProductInfoList(globalInstId, globalMcNo);
    }

    /**
     * 银行审批岗获取指定营销活动所有待审批数据
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp> 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:55
     */
    private List<TMPlatBizTmp> getAllMcTmpInfo(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        List<Object> tmMcMchntInfoList = new ArrayList<>();
        PageInfo pageInfo = new PageInfo();
        int i = 0;
        pageInfo.setPageIndex(i);
        pageInfo.setPageSize(9999);
        PlatBizTmpMapper platBizTmpMapper = new PlatBizTmpMapperImpl();
        PageResult tmMcMchntInfoPageInfo = platBizTmpMapper.selectSingleMcAllDetailInfoByBankAuditRole(moMcListInfoInObj, pageInfo);
        if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
            tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
        }
        while (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult() && tmMcMchntInfoPageInfo.getResult().size() >= 1) {
            i++;
            pageInfo.setPageIndex(i);
            tmMcMchntInfoPageInfo = platBizTmpMapper.selectSingleMcAllDetailInfoByBankAuditRole(moMcListInfoInObj, pageInfo);
            if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
                tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
            }
        }
        List<TMPlatBizTmp> tmpMcMchntInfoList = tmMcMchntInfoList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
        return tmpMcMchntInfoList;
    }

    /**
     * 营销活动信息数据库实体类和接口实体类数据转换
     *
     * @param tmMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @return cc.rengu.igas.momp.facade.bean.MchntFeeDiscountMcInfoBean 商户手续费减免类活动基本信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:27
     */
    private MchntFeeDiscountMcInfoBean convertMcInfo(TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo) {
        MchntFeeDiscountMcInfoBean mchntFeeDiscountMcInfoBean = new MchntFeeDiscountMcInfoBean();
        try {
            /* 法人机构号 */
            mchntFeeDiscountMcInfoBean.setInstId(tmMcMchntFeeDiscountInfo.getInstId());
            /* 营销活动编号 */
            mchntFeeDiscountMcInfoBean.setMcNo(tmMcMchntFeeDiscountInfo.getMcNo());
            /* 营销活动名称 */
            mchntFeeDiscountMcInfoBean.setMcName(tmMcMchntFeeDiscountInfo.getMcName());
            /* 营销活动类型 */
            mchntFeeDiscountMcInfoBean.setMcType(tmMcMchntFeeDiscountInfo.getMcType());
            /* 营销活动状态 */
            mchntFeeDiscountMcInfoBean.setMcStatus(tmMcMchntFeeDiscountInfo.getMcStatus());
            /* 活动起始日期 */
            mchntFeeDiscountMcInfoBean.setMcStartDate(tmMcMchntFeeDiscountInfo.getMcStartDate());
            /* 活动截止日期 */
            mchntFeeDiscountMcInfoBean.setMcEndDate(tmMcMchntFeeDiscountInfo.getMcEndDate());
            /* 活动结束日期 */
            mchntFeeDiscountMcInfoBean.setMcActualEndDate(tmMcMchntFeeDiscountInfo.getMcActualEndDate());
            mchntFeeDiscountMcInfoBean.setBudgetRechargeMethod(tmMcMchntFeeDiscountInfo.getBudgetRechargeMethod());
            /*存量商户达标条件 */
            mchntFeeDiscountMcInfoBean.setStockMchntFlag(tmMcMchntFeeDiscountInfo.getStockMchntFlag());
            /*存量商户支持类型 */
            mchntFeeDiscountMcInfoBean.setStockMchntType(tmMcMchntFeeDiscountInfo.getStockMchntType());
            /*有效交易下限 */
            mchntFeeDiscountMcInfoBean.setEffectiveLimit(tmMcMchntFeeDiscountInfo.getEffectiveLimit());
            /*新增商户支持标志 */
            mchntFeeDiscountMcInfoBean.setNewMchntFlag(tmMcMchntFeeDiscountInfo.getNewMchntFlag());
            /*新增商户免手续费周期 */
            mchntFeeDiscountMcInfoBean.setNewMchntPeriod(tmMcMchntFeeDiscountInfo.getNewMchntPeriod());
            /*新增商户周期顺延标志 */
            mchntFeeDiscountMcInfoBean.setPostponeFlag(tmMcMchntFeeDiscountInfo.getPostponeFlag());
            /*达标前手续费优惠规则 */
            mchntFeeDiscountMcInfoBean.setBeforeFlag(tmMcMchntFeeDiscountInfo.getBeforeFlag());
            /*达标后手续费优惠规则 */
            mchntFeeDiscountMcInfoBean.setAfterFlag(tmMcMchntFeeDiscountInfo.getAfterFlag());
            /*优惠退出标志 */
            mchntFeeDiscountMcInfoBean.setTerminationFlag(tmMcMchntFeeDiscountInfo.getTerminationFlag());
            /*统计周期 */
            mchntFeeDiscountMcInfoBean.setStatPeriod(tmMcMchntFeeDiscountInfo.getStatPeriod());
            /*单个商户优惠交易笔数上限 */
            mchntFeeDiscountMcInfoBean.setQuantityLimit(tmMcMchntFeeDiscountInfo.getQuantityLimit());
            /*单个商户优惠交易金额上限 */
            mchntFeeDiscountMcInfoBean.setAmountLimit(tmMcMchntFeeDiscountInfo.getAmountLimit());
            /*单个商户手续费优惠额上限 */
            mchntFeeDiscountMcInfoBean.setFeeLimit(tmMcMchntFeeDiscountInfo.getFeeLimit());
            /* 预算充值方式 */
            mchntFeeDiscountMcInfoBean.setBudgetRechargeMethod(tmMcMchntFeeDiscountInfo.getBudgetRechargeMethod());
            /* 预算 */
            mchntFeeDiscountMcInfoBean.setBudget(tmMcMchntFeeDiscountInfo.getBudget());
            /* 审批状态   */
            mchntFeeDiscountMcInfoBean.setAuditStatus(tmMcMchntFeeDiscountInfo.getAuditStatus());
            /* 创建人 */
            mchntFeeDiscountMcInfoBean.setOprId(tmMcMchntFeeDiscountInfo.getOprId());
            /* 创建时间 */
            mchntFeeDiscountMcInfoBean.setCreateTime(tmMcMchntFeeDiscountInfo.getCreateTime());
            /* 最后修改人 */
            mchntFeeDiscountMcInfoBean.setLastOprId(tmMcMchntFeeDiscountInfo.getLastOprId());
            /* 修改时间 */
            mchntFeeDiscountMcInfoBean.setUpdateTime(tmMcMchntFeeDiscountInfo.getUpdateTime());
            /* 审批拒绝原因 */
            mchntFeeDiscountMcInfoBean.setAuditRefuseReason(tmMcMchntFeeDiscountInfo.getAuditRefuseReason());
            /* 发布拒绝原因 */
            mchntFeeDiscountMcInfoBean.setPublishRefuseReason(tmMcMchntFeeDiscountInfo.getPublishRefuseReason());
            /* 备用字段1 */
            mchntFeeDiscountMcInfoBean.setRemark1(tmMcMchntFeeDiscountInfo.getRemark1());
            /* 备用字段2 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmMcMchntFeeDiscountInfo.getRemark2());
            /* 备用字段3 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmMcMchntFeeDiscountInfo.getRemark3());
            /* 备用字段4 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmMcMchntFeeDiscountInfo.getRemark4());
            /* 备用字段5 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmMcMchntFeeDiscountInfo.getRemark5());
            /* 月均存款平均月数 */
            mchntFeeDiscountMcInfoBean.setDepositMonNum(tmMcMchntFeeDiscountInfo.getDepositMonNum());
            /* 新增商户免交易金额上限 */
            mchntFeeDiscountMcInfoBean.setNewMchntAmountLimit(tmMcMchntFeeDiscountInfo.getNewMchntAmountLimit());
            /* 强制终止原因*/
            mchntFeeDiscountMcInfoBean.setNfrcTmnlRsn(tmMcMchntFeeDiscountInfo.getNfrcTmnlRsn());
            /* 活动支持商户类型*/
            mchntFeeDiscountMcInfoBean.setAvySprtMrctTyp(tmMcMchntFeeDiscountInfo.getavySprtMrctTyp());
            /* 新增商户免费额度类型 */
            String newmrctFreeLmtTyp = tmMcMchntFeeDiscountInfo.getNewmrctFreeLmtTyp();
            if (null == newmrctFreeLmtTyp) {
                mchntFeeDiscountMcInfoBean.setNewMchntAmountType(CommonConstant.ZERO_COMMON_CONSTANT);
            } else {
                mchntFeeDiscountMcInfoBean.setNewMchntAmountType(tmMcMchntFeeDiscountInfo.getNewmrctFreeLmtTyp());
            }
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mchntFeeDiscountMcInfoBean;
    }

    /**
     * 商户手续费减免类营销活动基本信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.MchntFeeDiscountMcInfoBean 商户手续费减免类活动基本信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:35
     */
    private MchntFeeDiscountMcInfoBean convertTmpMcInfo(TMPlatBizTmp tmPlatBizTmp) {
        MchntFeeDiscountMcInfoBean mchntFeeDiscountMcInfoBean = new MchntFeeDiscountMcInfoBean();
        try {

            JsonTmpMfdMcInfo jsonTmpMfdMcInfo = JsonOperation.parseMfdMcInfoTmpBizData1(tmPlatBizTmp, rglog);

            /* 营销活动编号 */
            mchntFeeDiscountMcInfoBean.setMcNo(jsonTmpMfdMcInfo.getMcNo());
            /* 营销活动名称 */
            mchntFeeDiscountMcInfoBean.setMcName(jsonTmpMfdMcInfo.getMcName());
            /* 营销活动类型 */
            mchntFeeDiscountMcInfoBean.setMcType(jsonTmpMfdMcInfo.getMcType());
            /* 营销活动状态 */
            mchntFeeDiscountMcInfoBean.setMcStatus(jsonTmpMfdMcInfo.getMcStatus());
            /* 活动起始日期 */
            mchntFeeDiscountMcInfoBean.setMcStartDate(jsonTmpMfdMcInfo.getMcStartDate());
            /* 活动截止日期 */
            mchntFeeDiscountMcInfoBean.setMcEndDate(jsonTmpMfdMcInfo.getMcEndDate());
            /* 活动结束日期 */
            mchntFeeDiscountMcInfoBean.setMcActualEndDate(jsonTmpMfdMcInfo.getMcActualEndDate());
            mchntFeeDiscountMcInfoBean.setBudgetRechargeMethod(jsonTmpMfdMcInfo.getBudgetRechargeMethod());
            /*存量商户达标条件 */
            mchntFeeDiscountMcInfoBean.setStockMchntFlag(jsonTmpMfdMcInfo.getStockMchntFlag());
            /*存量商户支持类型 */
            mchntFeeDiscountMcInfoBean.setStockMchntType(jsonTmpMfdMcInfo.getStockMchntType());
            /*有效交易下限 */
            mchntFeeDiscountMcInfoBean.setEffectiveLimit(jsonTmpMfdMcInfo.getEffectiveLimit());
            /*新增商户支持标志 */
            mchntFeeDiscountMcInfoBean.setNewMchntFlag(jsonTmpMfdMcInfo.getNewMchntFlag());
            /*新增商户免手续费周期 */
            mchntFeeDiscountMcInfoBean.setNewMchntPeriod(jsonTmpMfdMcInfo.getNewMchntPeriod());
            /*新增商户周期顺延标志 */
            mchntFeeDiscountMcInfoBean.setPostponeFlag(jsonTmpMfdMcInfo.getPostponeFlag());
            /*达标前手续费优惠规则 */
            mchntFeeDiscountMcInfoBean.setBeforeFlag(jsonTmpMfdMcInfo.getBeforeFlag());
            /*达标后手续费优惠规则 */
            mchntFeeDiscountMcInfoBean.setAfterFlag(jsonTmpMfdMcInfo.getAfterFlag());
            /*优惠退出标志 */
            mchntFeeDiscountMcInfoBean.setTerminationFlag(jsonTmpMfdMcInfo.getTerminationFlag());
            /*统计周期 */
            mchntFeeDiscountMcInfoBean.setStatPeriod(jsonTmpMfdMcInfo.getStatPeriod());
            /*单个商户优惠交易笔数上限 */
            mchntFeeDiscountMcInfoBean.setQuantityLimit(jsonTmpMfdMcInfo.getQuantityLimit());
            /*单个商户优惠交易金额上限 */
            mchntFeeDiscountMcInfoBean.setAmountLimit(jsonTmpMfdMcInfo.getAmountLimit());
            /*单个商户手续费优惠额上限 */
            mchntFeeDiscountMcInfoBean.setFeeLimit(jsonTmpMfdMcInfo.getFeeLimit());
            /* 预算充值方式 */
            mchntFeeDiscountMcInfoBean.setBudgetRechargeMethod(jsonTmpMfdMcInfo.getBudgetRechargeMethod());
            /* 预算 */
            mchntFeeDiscountMcInfoBean.setBudget(jsonTmpMfdMcInfo.getBudget());
            /* 审批状态   */
            mchntFeeDiscountMcInfoBean.setAuditStatus(tmPlatBizTmp.getAuditStatus());
            /* 创建人 */
            mchntFeeDiscountMcInfoBean.setOprId(tmPlatBizTmp.getOprId());
            /* 创建时间 */
            mchntFeeDiscountMcInfoBean.setCreateTime(tmPlatBizTmp.getCreateTime());
            /* 最后修改人 */
            mchntFeeDiscountMcInfoBean.setLastOprId(tmPlatBizTmp.getLastOprId());
            /* 修改时间 */
            mchntFeeDiscountMcInfoBean.setUpdateTime(tmPlatBizTmp.getLastUpdateTime());
            /* 审批拒绝原因 */
            mchntFeeDiscountMcInfoBean.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
            /* 发布拒绝原因 */
            mchntFeeDiscountMcInfoBean.setPublishRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
            /* 备用字段1 */
            mchntFeeDiscountMcInfoBean.setRemark1(tmPlatBizTmp.getRemark1());
            /* 备用字段2 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmPlatBizTmp.getRemark2());
            /* 备用字段3 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmPlatBizTmp.getRemark3());
            /* 备用字段4 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmPlatBizTmp.getRemark4());
            /* 备用字段5 */
            mchntFeeDiscountMcInfoBean.setRemark2(tmPlatBizTmp.getRemark5());
            /* 月均存款平均月数 */
            mchntFeeDiscountMcInfoBean.setDepositMonNum(jsonTmpMfdMcInfo.getDepositMonNum());
            /* 新增商户免交易金额上限 */
            mchntFeeDiscountMcInfoBean.setNewMchntAmountLimit(jsonTmpMfdMcInfo.getNewMchntAmountLimit());
            /* 活动支持商户类型*/
            mchntFeeDiscountMcInfoBean.setAvySprtMrctTyp(jsonTmpMfdMcInfo.getavySprtMrctTyp());
            /* 新增商户免费额度类型 */
            String newmrctFreeLmtTyp = jsonTmpMfdMcInfo.getNewmrctFreeLmtTyp();
            if (null == newmrctFreeLmtTyp) {
                mchntFeeDiscountMcInfoBean.setNewMchntAmountType(CommonConstant.ZERO_COMMON_CONSTANT);
            } else {
                mchntFeeDiscountMcInfoBean.setNewMchntAmountType(jsonTmpMfdMcInfo.getNewmrctFreeLmtTyp());
            }
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mchntFeeDiscountMcInfoBean;
    }

    /**
     * 营销活动机构信息数据库实体类和接口实体类数据转换
     *
     * @param mcOrgInfo 营销活动机构信息表
     * @return cc.rengu.igas.momp.facade.bean.McOrgInfoBean 营销活动机构信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:33
     */
    private McOrgInfoBean convertMcOrgInfo(TMMcOrgInfo mcOrgInfo) {
        McOrgInfoBean mcOrgInfoBean = new McOrgInfoBean();
        try {
            /* 机构编号 */
            mcOrgInfoBean.setOrgId(mcOrgInfo.getOrgId());
            /* 机构层级 */
            mcOrgInfoBean.setOrgHierarchy(mcOrgInfo.getOrgHierarchy());
            /* 机构名称 */
            mcOrgInfoBean.setOrgName(mcOrgInfo.getOrgName());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动机构信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcOrgInfoBean;
    }

    /**
     * 营销活动机构信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McOrgInfoBean 营销活动机构信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:01
     */
    private McOrgInfoBean convertTmpMcOrgInfo(TMPlatBizTmp tmPlatBizTmp) {

        McOrgInfoBean mcOrgInfoBean = new McOrgInfoBean();
        try {

            JsonTmpMcOrgInfo jsonTmpMcOrgInfo = JsonOperation.parseTmpMcOrgInfoBizData1(tmPlatBizTmp, rglog);

            /* 机构编号 */
            mcOrgInfoBean.setOrgId(jsonTmpMcOrgInfo.getOrgId());
            /* 机构层级 */
            mcOrgInfoBean.setOrgHierarchy(jsonTmpMcOrgInfo.getOrgHierarchy());
            /* 机构名称 */
            mcOrgInfoBean.setOrgName(jsonTmpMcOrgInfo.getOrgName());

        } catch (Exception e) {
            rglog.error("转换临时表营销活动机构信息异常,异常信息:<{}>", StringUtil.ExceptionToString(e));
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcOrgInfoBean;
    }

    /**
     * 营销活动商户信息数据库实体类和接口实体类数据转换
     *
     * @param object 营销活动商户信息表
     * @return cc.rengu.igas.momp.facade.bean.McMchntInfoBean 营销活动商户信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:33
     */
    private McMchntInfoBean convertMcMchntInfo(Object object) {
        McMchntInfoBean mcMchntInfoBean = new McMchntInfoBean();
        TMMcMchntInfo mcMchntInfo = (TMMcMchntInfo) object;
        try {
            /* 商户范围类型 */
            mcMchntInfoBean.setMchntType(mcMchntInfo.getMchntType());
            /* 商户范围号 */
            mcMchntInfoBean.setMchntNo(mcMchntInfo.getMchntNo());
            /* 商户范围名称 */
            mcMchntInfoBean.setMchntName(mcMchntInfo.getMchntName());
            /* 新增商户标志 */
            mcMchntInfoBean.setNewMchntFlag(mcMchntInfo.getNewMchntFlag());
            /* 退出标志 */
            mcMchntInfoBean.setExitFlag(mcMchntInfo.getExitFlag());
            /* 操作类型 */
            if ((mcMchntInfo.getNewMchntFlag().equals(CommonConstant.MCHNT_REFUSE_FLAG) || mcMchntInfo.getNewMchntFlag().equals(CommonConstant.MCHNT_NEW_FLAG)) && mcMchntInfo.getExitFlag().equals(CommonConstant.MC_EXIT_FLAG)) {
                mcMchntInfoBean.setOprType(CommonConstant.BIZ_OPR_INSERT);
            } else {
                mcMchntInfoBean.setOprType(CommonConstant.EMPTY_STRING);
            }


        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcMchntInfoBean;
    }

    /**
     * 营销活动商户信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McMchntInfoBean 营销活动商户信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:13
     */
    private McMchntInfoBean convertTmpMcMchntInfo(TMPlatBizTmp tmPlatBizTmp) {

        McMchntInfoBean mcMchntInfoBean = new McMchntInfoBean();
        try {

            JsonTmpMcMchntInfo jsonTmpMcMchntInfo = JsonOperation.parseTmpMcMchntInfoBizData1(tmPlatBizTmp, rglog);

            /* 商户范围类型 */
            mcMchntInfoBean.setMchntType(jsonTmpMcMchntInfo.getMchntType());
            /* 商户范围号 */
            mcMchntInfoBean.setMchntNo(jsonTmpMcMchntInfo.getMchntNo());
            /* 商户范围名称 */
            mcMchntInfoBean.setMchntName(jsonTmpMcMchntInfo.getMchntName());
            if (tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.NEW_AUDIT_PROCESSING.getAuditStatusCode()) || tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.NEW_AUDIT_REJECT.getAuditStatusCode())
                    || tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.PUBLISH_AUDIT_REJECT.getAuditStatusCode())) {
                /* 审批状态*/
                mcMchntInfoBean.setOprType(CommonConstant.BIZ_OPR_INSERT);
            }

        } catch (Exception e) {
            rglog.error("转换临时表营销活动机构信息异常,异常信息:<{}>", StringUtil.ExceptionToString(e));
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcMchntInfoBean;
    }

    /**
     * 营销活动规则信息数据库实体类和接口实体类数据转换
     *
     * @param tmMcMchntFeeDiscountRuleInfo 商户手续费减免类营销活动规则表
     * @return cc.rengu.igas.momp.facade.bean.MoneyOffRuleInfoBean 商户手续费减免类营销活动规则信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:32
     */
    private MchntFeeDiscountRuleInfoBean convertMcRuleInfo(TMMcMchntFeeDiscountRuleInfo tmMcMchntFeeDiscountRuleInfo) {

        MchntFeeDiscountRuleInfoBean mchntFeeDiscountRuleInfoBean = new MchntFeeDiscountRuleInfoBean();

        try {

            /* 顺序号  */
            mchntFeeDiscountRuleInfoBean.setRuleIndex(tmMcMchntFeeDiscountRuleInfo.getRuleIndex());
            /* 优惠力度下限 */
            mchntFeeDiscountRuleInfoBean.setCriteriaFloor(tmMcMchntFeeDiscountRuleInfo.getCriteriaFloor());
            /* 优惠力度上限 */
            mchntFeeDiscountRuleInfoBean.setCriteriaCelling(tmMcMchntFeeDiscountRuleInfo.getCriteriaCelling());
            /* 优惠周期 */
            mchntFeeDiscountRuleInfoBean.setDiscountPeriod(tmMcMchntFeeDiscountRuleInfo.getDiscountPeriod());
            /* 优惠类型 */
            mchntFeeDiscountRuleInfoBean.setDiscountType(tmMcMchntFeeDiscountRuleInfo.getDiscountType());
            /* 优惠力度 */
            mchntFeeDiscountRuleInfoBean.setDiscount(tmMcMchntFeeDiscountRuleInfo.getDiscount());
            /* 计算规则编号 */
            mchntFeeDiscountRuleInfoBean.setCalRuleNo(tmMcMchntFeeDiscountRuleInfo.getCalRuleNo());
            /* 优惠上限 */
            mchntFeeDiscountRuleInfoBean.setDiscountLimit(tmMcMchntFeeDiscountRuleInfo.getDiscountLimit());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动规则信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mchntFeeDiscountRuleInfoBean;
    }

    /**
     * 营销活动时间信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.MchntFeeDiscountRuleInfoBean 商户手续费减免类活动规则信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:30
     */
    private MchntFeeDiscountRuleInfoBean convertTmpMcRuleInfo(TMPlatBizTmp tmPlatBizTmp) {

        MchntFeeDiscountRuleInfoBean mchntFeeDiscountRuleInfoBean = new MchntFeeDiscountRuleInfoBean();

        try {

            JsonTmpMfdMcRuleInfo jsonTmpMfdMcRuleInfo = JsonOperation.parseTmpMfdMcRuleInfoBizData1(tmPlatBizTmp, rglog);

            /* 顺序号  */
            mchntFeeDiscountRuleInfoBean.setRuleIndex(jsonTmpMfdMcRuleInfo.getRuleIndex());
            /* 优惠力度下限 */
            mchntFeeDiscountRuleInfoBean.setCriteriaFloor(jsonTmpMfdMcRuleInfo.getCriteriaFloor());
            /* 优惠力度上限 */
            mchntFeeDiscountRuleInfoBean.setCriteriaCelling(jsonTmpMfdMcRuleInfo.getCriteriaCelling());
            /* 优惠周期 */
            mchntFeeDiscountRuleInfoBean.setDiscountPeriod(jsonTmpMfdMcRuleInfo.getDiscountPeriod());
            /* 优惠类型 */
            mchntFeeDiscountRuleInfoBean.setDiscountType(jsonTmpMfdMcRuleInfo.getDiscountType());
            /* 优惠力度 */
            mchntFeeDiscountRuleInfoBean.setDiscount(jsonTmpMfdMcRuleInfo.getDiscount());
            /* 计算规则编号 */
            mchntFeeDiscountRuleInfoBean.setCalRuleNo(jsonTmpMfdMcRuleInfo.getCalRuleNo());
            /* 优惠上限 */
            mchntFeeDiscountRuleInfoBean.setDiscountLimit(jsonTmpMfdMcRuleInfo.getDiscountLimit());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动规则信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mchntFeeDiscountRuleInfoBean;
    }

    /**
     * 营销活动支付产品信息数据库实体类和接口实体类数据转换
     *
     * @param mcProductInfo 营销活动产品信息表
     * @return cc.rengu.igas.momp.facade.bean.McProductInfoBean 营销活动产品对象
     * @author Jinan Liu
     * @date 2020/4/1 10:32
     */
    private McProductInfoBean convertMcProductInfo(TMMcProductInfo mcProductInfo) {
        McProductInfoBean mcProductInfoBean = new McProductInfoBean();
        try {
            /* 业务产品代码 */
            mcProductInfoBean.setBizProdCode(mcProductInfo.getBizProdCode());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动支付产品信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcProductInfoBean;
    }

    /**
     * 营销活动产品信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McProductInfoBean 营销活动产品对象
     * @author Jinan Liu
     * @date 2020/5/28 20:29
     */
    private McProductInfoBean convertTmpMcProductInfo(TMPlatBizTmp tmPlatBizTmp) {
        McProductInfoBean mcProductInfoBean = new McProductInfoBean();
        try {

            JsonTmpMcProdInfo jsonTmpMcProdInfo = JsonOperation.parseTmpMcProdInfoBizData1(tmPlatBizTmp, rglog);

            /* 业务产品代码 */
            mcProductInfoBean.setBizProdCode(jsonTmpMcProdInfo.getBizProdCode());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动支付产品信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcProductInfoBean;
    }
}
